home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / CIncludes / Events.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-11  |  6.9 KB  |  243 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Events.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __EVENTS__
  18. #define __EVENTS__
  19.  
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifndef __QUICKDRAW__
  27. #include <Quickdraw.h>
  28. #endif
  29. /*    #include <MixedMode.h>                                        */
  30. /*    #include <QuickdrawText.h>                                    */
  31.  
  32. #ifndef __OSUTILS__
  33. #include <OSUtils.h>
  34. #endif
  35. /*    #include <Memory.h>                                            */
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #if GENERATINGPOWERPC
  42. #pragma options align=mac68k
  43. #endif
  44.  
  45. #ifdef __CFM68K__
  46. #pragma lib_export on
  47. #endif
  48.  
  49.  
  50. enum {
  51.     nullEvent                    = 0,
  52.     mouseDown                    = 1,
  53.     mouseUp                        = 2,
  54.     keyDown                        = 3,
  55.     keyUp                        = 4,
  56.     autoKey                        = 5,
  57.     updateEvt                    = 6,
  58.     diskEvt                        = 7,
  59.     activateEvt                    = 8,
  60.     osEvt                        = 15,
  61. /* event mask equates */
  62.     mDownMask                    = 0x0002,                        /* mouse button pressed */
  63.     mUpMask                        = 0x0004,                        /* mouse button released */
  64.     keyDownMask                    = 0x0008,                        /* key pressed */
  65.     keyUpMask                    = 0x0010,                        /* key released */
  66.     autoKeyMask                    = 0x0020,                        /* key repeatedly held down */
  67.     updateMask                    = 0x0040,                        /* window needs updating */
  68.     diskMask                    = 0x0080,                        /* disk inserted */
  69.     activMask                    = 0x0100,                        /* activate/deactivate window */
  70.     highLevelEventMask            = 0x0400,                        /* high-level events (includes AppleEvents) */
  71.     osMask                        = 0x8000,                        /* operating system events (suspend, resume) */
  72.     everyEvent                    = 0xFFFF                        /* all of the above */
  73. };
  74.  
  75. enum {
  76. /* event message equates */
  77.     charCodeMask                = 0x000000FF,
  78.     keyCodeMask                    = 0x0000FF00,
  79.     adbAddrMask                    = 0x00FF0000,
  80.     osEvtMessageMask            = 0xFF000000L,
  81. /* OS event messages.  Event (sub)code is in the high byte of the message field. */
  82.     mouseMovedMessage            = 0x00FA,
  83.     suspendResumeMessage        = 0x0001,
  84.     resumeFlag                    = 1,                            /* Bit 0 of message indicates resume vs suspend */
  85.     convertClipboardFlag        = 2,                            /* Bit 1 in resume message indicates clipboard change */
  86. /* modifiers */
  87.     activeFlag                    = 0x0001,                        /* Bit 0 of modifiers for activateEvt and mouseDown events */
  88.     btnState                    = 0x0080,                        /* Bit 7 of low byte is mouse button state */
  89.     cmdKey                        = 0x0100,                        /* Bit 0 of high byte */
  90.     shiftKey                    = 0x0200,                        /* Bit 1 of high byte */
  91.     alphaLock                    = 0x0400,                        /* Bit 2 of high byte */
  92.     optionKey                    = 0x0800,                        /* Bit 3 of high byte */
  93.     controlKey                    = 0x1000,                        /* Bit 4 of high byte */
  94. /* obsolete equates */
  95.     networkEvt                    = 10,
  96.     driverEvt                    = 11,
  97.     app1Evt                        = 12,
  98.     app2Evt                        = 13
  99. };
  100.  
  101. enum {
  102.     app3Evt                        = 14,
  103.     app4Evt                        = 15,
  104.     networkMask                    = 0x0400,
  105.     driverMask                    = 0x0800,
  106.     app1Mask                    = 0x1000,
  107.     app2Mask                    = 0x2000,
  108.     app3Mask                    = 0x4000,
  109.     app4Mask                    = 0x8000
  110. };
  111.  
  112. struct EventRecord {
  113.     short                            what;
  114.     long                            message;
  115.     long                            when;
  116.     Point                            where;
  117.     short                            modifiers;
  118. };
  119. typedef struct EventRecord EventRecord;
  120.  
  121. typedef long KeyMap[4];
  122.  
  123. struct EvQEl {
  124.     QElemPtr                        qLink;
  125.     short                            qType;
  126.     short                            evtQWhat;                    /* this part is identical to the EventRecord as... */
  127.     long                            evtQMessage;                /* defined in ToolIntf */
  128.     long                            evtQWhen;
  129.     Point                            evtQWhere;
  130.     short                            evtQModifiers;
  131. };
  132. typedef struct EvQEl EvQEl;
  133.  
  134. typedef EvQEl *EvQElPtr;
  135.  
  136. typedef void (*GetNextEventFilterProcPtr)(EventRecord *theEvent, Boolean *result);
  137.  
  138. #if GENERATINGCFM
  139. typedef UniversalProcPtr GetNextEventFilterUPP;
  140. #else
  141. typedef Register68kProcPtr GetNextEventFilterUPP;
  142. #endif
  143.  
  144. enum {
  145.     uppGetNextEventFilterProcInfo = SPECIAL_CASE_PROCINFO( kSpecialCaseGNEFilterProc )
  146. };
  147.  
  148. #if GENERATINGCFM
  149. #define NewGetNextEventFilterProc(userRoutine)        \
  150.         (GetNextEventFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, GetCurrentArchitecture())
  151. #else
  152. #define NewGetNextEventFilterProc(userRoutine)        \
  153.         ((GetNextEventFilterUPP) (userRoutine))
  154. #endif
  155.  
  156. #if GENERATINGCFM
  157. #define CallGetNextEventFilterProc(userRoutine, theEvent, result)        \
  158.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, (theEvent), (result))
  159. #else
  160. /* (*GetNextEventFilterProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  161. #endif
  162.  
  163. typedef GetNextEventFilterUPP GNEFilterUPP;
  164.  
  165. extern pascal long GetDblTime( void )
  166.     TWOWORDINLINE( 0x2EB8, 0x02F0 ); /* MOVE.L $02F0,(SP) */
  167. extern pascal long GetCaretTime( void )
  168.     TWOWORDINLINE( 0x2EB8, 0x02F4 ); /* MOVE.L $02F4,(SP) */
  169. extern pascal void SetEventMask( short value )
  170.     TWOWORDINLINE( 0x31DF, 0x0144 ); /* MOVE.W (SP)+,$0144 */
  171. extern pascal QHdrPtr GetEventQueue(void)
  172.  THREEWORDINLINE(0x2EBC, 0x0000, 0x014A);
  173. extern pascal Boolean GetNextEvent(short eventMask, EventRecord *theEvent)
  174.  ONEWORDINLINE(0xA970);
  175. extern pascal Boolean WaitNextEvent(short eventMask, EventRecord *theEvent, unsigned long sleep, RgnHandle mouseRgn)
  176.  ONEWORDINLINE(0xA860);
  177. extern pascal Boolean EventAvail(short eventMask, EventRecord *theEvent)
  178.  ONEWORDINLINE(0xA971);
  179. extern pascal void GetMouse(Point *mouseLoc)
  180.  ONEWORDINLINE(0xA972);
  181. extern pascal Boolean Button(void)
  182.  ONEWORDINLINE(0xA974);
  183. extern pascal Boolean StillDown(void)
  184.  ONEWORDINLINE(0xA973);
  185. extern pascal Boolean WaitMouseUp(void)
  186.  ONEWORDINLINE(0xA977);
  187. extern pascal void GetKeys(KeyMap theKeys)
  188.  ONEWORDINLINE(0xA976);
  189. extern pascal long KeyTranslate(const void *transData, short keycode, long *state)
  190.  ONEWORDINLINE(0xA9C3);
  191. extern pascal unsigned long TickCount(void)
  192.  ONEWORDINLINE(0xA975);
  193.  
  194. #if !GENERATINGCFM
  195. #pragma parameter __D0 PostEvent(__A0, __D0)
  196. #endif
  197. extern pascal OSErr PostEvent(short eventNum, long eventMsg)
  198.  ONEWORDINLINE(0xA02F);
  199.  
  200. #if !GENERATINGCFM
  201. #pragma parameter __D0 PPostEvent(__A0, __D0, __A1)
  202. #endif
  203. extern pascal OSErr PPostEvent(short eventCode, long eventMsg, EvQElPtr *qEl)
  204.  TWOWORDINLINE(0xA12F, 0x2288);
  205.  
  206. #if !GENERATINGCFM
  207. #pragma parameter __D0 OSEventAvail(__D0, __A0)
  208. #endif
  209. extern pascal Boolean OSEventAvail(short mask, EventRecord *theEvent)
  210.  TWOWORDINLINE(0xA030, 0x5240);
  211.  
  212. #if !GENERATINGCFM
  213. #pragma parameter __D0 GetOSEvent(__D0, __A0)
  214. #endif
  215. extern pascal Boolean GetOSEvent(short mask, EventRecord *theEvent)
  216.  TWOWORDINLINE(0xA031, 0x5240);
  217. extern pascal void FlushEvents(short whichMask, short stopMask)
  218.  TWOWORDINLINE(0x201F, 0xA032);
  219. extern pascal void SystemClick(const EventRecord *theEvent, WindowPtr theWindow)
  220.  ONEWORDINLINE(0xA9B3);
  221. extern pascal void SystemTask(void)
  222.  ONEWORDINLINE(0xA9B4);
  223. extern pascal Boolean SystemEvent(const EventRecord *theEvent)
  224.  ONEWORDINLINE(0xA9B2);
  225. #if OLDROUTINENAMES
  226. #define KeyTrans(transData, keycode, state) KeyTranslate(transData, keycode, state)
  227. #define GetEvQHdr() GetEventQueue()
  228. #endif
  229.  
  230. #ifdef __CFM68K__
  231. #pragma lib_export off
  232. #endif
  233.  
  234. #if GENERATINGPOWERPC
  235. #pragma options align=reset
  236. #endif
  237.  
  238. #ifdef __cplusplus
  239. }
  240. #endif
  241.  
  242. #endif /* __EVENTS__ */
  243.